package com.tea.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tea.Model.DeliveryCompany;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 运力公司Mapper接口
 */
@Mapper
public interface DeliveryCompanyMapper extends BaseMapper<DeliveryCompany> {
    
    /**
     * 根据运力公司名称查询编码
     * @param deliveryName 运力公司名称
     * @return 运力公司编码
     */
    @Select("SELECT delivery_id FROM delivery_company WHERE delivery_name = #{deliveryName} AND status = 1 LIMIT 1")
    String getDeliveryIdByName(@Param("deliveryName") String deliveryName);
    
    /**
     * 根据运力公司名称模糊查询编码
     * @param deliveryName 运力公司名称
     * @return 运力公司编码
     */
    @Select("SELECT delivery_id FROM delivery_company WHERE delivery_name LIKE CONCAT('%', #{deliveryName}, '%') AND status = 1 LIMIT 1")
    String getDeliveryIdByNameLike(@Param("deliveryName") String deliveryName);
    
    /**
     * 获取所有启用的运力公司
     * @return 运力公司列表
     */
    @Select("SELECT * FROM delivery_company WHERE status = 1 ORDER BY delivery_name")
    List<DeliveryCompany> selectActiveDeliveryCompanies();
}